package com.hmall.search.mq;

import com.hmall.search.service.ISearchService;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HmallListener {
    @Autowired
    private ISearchService iSearchService;

    /**
     * 监听商品新增或修改的业务
     * @param id 商品id
     */
    @RabbitListener(queuesToDeclare = @Queue("insert.Queue"))
    public void listenHmallDown1(Long id){
        iSearchService.insertById(id);
    }

    /**
     * 监听商品新增或修改的业务
     * @param id 商品id
     */
    @RabbitListener(queuesToDeclare = @Queue("delete.Queue"))
    public void listenHmallDown2(Long id){
        iSearchService.deleteById(id);
    }

}
